package com.jxsm.service.impl;

import com.jxsm.dao.ExtCProductDao;
import com.jxsm.dao.SqlTypeDao;
import com.jxsm.page.Page;
import com.jxsm.pojo.ExtCProduct;
import com.jxsm.pojo.SqlType;
import com.jxsm.service.ExtCProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * Created by Administrator on 2016/11/4.
 */
@Service
public class ExtCProductServiceimpl implements ExtCProductService{
    @Autowired private ExtCProductDao extCProductDao;
    @Autowired private SqlTypeDao sqlTypeDao;
    public void insert(ExtCProduct entity) {
        entity.setId(UUID.randomUUID().toString());
        if(entity.getPrice()!=null|entity.getCnumber()!=null){
            entity.setAmount(entity.getPrice()*entity.getCnumber());
        }
         extCProductDao.insert(entity);
    }

    public void update(ExtCProduct entity) {
        extCProductDao.update(entity);
    }

    public void deleteById(Serializable id) {
        extCProductDao.deleteById(id);
    }

    public void delete(Serializable[] id) {
        extCProductDao.deleteById(id);
    }

    public List<ExtCProduct> findPage(Page page) {
        return extCProductDao.findPage(page);
    }

    public List<ExtCProduct> find(Map map) {
        return extCProductDao.findAll(map);
    }

    public ExtCProduct get(Serializable id) {
        return extCProductDao.get(id);
    }

    public List<SqlType> list(Map map) {
        return sqlTypeDao.findAll(null);
    }

}
